home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -serious- / programming / other / tandem / teaching / 30.asm < prev    next >
Assembly Source File  |  1999-09-06  |  3KB  |  85 lines

  1. * 30.asm     Demonstrate TLKeyboard     Version 0.01   8.6.99
  2.  
  3.  
  4.  include 'Front.i'  ;*** change to 'Tandem.i' to step thru TL's ***
  5.  
  6.  
  7. ; I should stress again that it is a good idea to chnage the above to
  8. ; Tandem.i, which allows you to step thru tandem.library routines.
  9. ;
  10. ; If you have done so...
  11. ; When you are stepping Program, and you come to a TL call, e.g.
  12. ;
  13. ;   jsr _LVO\1
  14. ;
  15. ; then instead of single stepping it (which jumps right through it), put a
  16. ; breakpoint at the relevent TL routine. e.g. if you are in TLwindow, put
  17. ; the breakpoint at the start of TLWindow. If you have included Tandem.i,
  18. ; then when you run, the breakpoint will trap execution at the start of
  19. ; TLWindow. You can then step it through, and back to where is was called
  20. ; in Program. That is to say, Tandem.i forces calls to tandem.library to be
  21. ; diverted to itself, so you can step them through.
  22.  
  23. ; This program demonstrates the use of TLKeyboard which which returns an
  24. ; ASCII value in D0, or dummy values for non-printable keys. It you are
  25. ; stepping through TLKeyboard, you should place your breakpoint within the
  26. ; sub-subroutine TLMget, just AFTER the BSR to TLMmess. This allows you to
  27. ; first type something into the window, before jumping back to Tandem.
  28.  
  29.  
  30. strings: dc.b 0
  31.  dc.b 'Press or click anything - Close window when finished',0 ;1
  32.  dc.b 'D0 D1 D2 D3',0 ;2
  33. st_3: dc.b '.. .. .. .. ',0 ;3
  34. st_4: dc.b 'TLKeyboard demo',0 ;4
  35.  dc.b 'Error: out of memory',0 ;5
  36.  ds.w 0
  37.  
  38. * open screen & window; show Keyboard until Close Window clicked
  39. Program:
  40.  TLwindow #1,#0,#0,#200,#100,#400,#150,#0,#st_4 ;open window 1
  41.  beq Pr_bad                           ;bad if out of chip ram
  42.  TLstrbuf #2                          ;string 2 to buffer
  43.  TLtext #10,#5                        ;print string 2 at 10,5
  44.  
  45. Pr_wait:
  46.  TLkeyboard              ;get from keyboard - see TLKeyboard in tandem.guide
  47.  cmp.b #$93,d0           ;($93 is my dummy code for IDCMP_CLOSEWINDOW)
  48.  beq.s Pr_close          ;quit if Close Window clicked
  49.  lea st_3,a0             ;poke the inputs (D0-D3) into string 3
  50.  bsr Hex
  51.  move.l d1,d0
  52.  bsr Hex
  53.  move.l d2,d0
  54.  bsr Hex
  55.  move.l d3,d0
  56.  bsr Hex
  57.  TLstrbuf #3             ;string 3 to buffer
  58.  TLtext #10,#24          ;print string 3 at 10,24
  59.  bra Pr_wait             ;wait for next input
  60. Pr_close:
  61.  rts                     ;return ok
  62. Pr_bad:
  63.  TLbad #5
  64.  rts
  65.  
  66.  
  67. * put ASCII (2 hex digits) for hex of D0.B in (A0)+
  68. Hex:
  69.  move.l d0,-(a7)
  70.  lsr.l #4,d0
  71.  bsr.s Hx_n
  72.  move.l (a7)+,d0
  73.  bsr.s Hx_n
  74.  move.b #$20,(a0)+
  75.  rts
  76. Hx_n:
  77.  and.b #15,d0
  78.  add.b #'0',d0
  79.  cmp.b #':',d0
  80.  bcs.s Hx_p
  81.  add.b #'A'-':',d0
  82. Hx_p:
  83.  move.b d0,(a0)+
  84.  rts
  85.